package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class employeeContainer here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class EmployeeContainer
{
    private ArrayList<Employee> employeeContainer;
    private static EmployeeContainer instance;
    public EmployeeContainer()
    {
        employeeContainer = new ArrayList<Employee>();
    }

    public static EmployeeContainer getInstance()
    {
        if(instance == null)
        {
            instance = new EmployeeContainer();
        }
        return instance;
    }

    public Employee findEmployeeById(int id){
        Employee eObject = null;
        int index = 0;
        boolean found = false;
        while(index < employeeContainer.size() && !found)
        {
            eObject = employeeContainer.get(index); 
            if(eObject.getEmployeeId() == id)
            {
                found = true;
            }
            else{
                index++;
            }
        }//end while
        return employeeContainer.get(index);

    }
    
    public void addEmployee(Employee e)
    {
        employeeContainer.add(e);
    }
    
    public void deleteEmployee(Employee e)
    {
        if(employeeContainer.contains(e))
            employeeContainer.remove(e);
    }
    
    
}
